{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-08-10T05:55:32.746492Z",
     "start_time": "2025-08-10T05:55:32.260021Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ],
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-10T05:55:32.779310Z",
     "start_time": "2025-08-10T05:55:32.757900Z"
    }
   },
   "cell_type": "code",
   "source": [
    "data = pd.read_csv('../data/train.csv')\n",
    "data.head()"
   ],
   "id": "c2c0a4fba0a9e7c6",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   Attrition  Age     BusinessTravel              Department  \\\n",
       "0          0   37      Travel_Rarely  Research & Development   \n",
       "1          0   54  Travel_Frequently  Research & Development   \n",
       "2          1   34  Travel_Frequently  Research & Development   \n",
       "3          0   39      Travel_Rarely  Research & Development   \n",
       "4          1   28  Travel_Frequently  Research & Development   \n",
       "\n",
       "   DistanceFromHome  Education EducationField  EmployeeNumber  \\\n",
       "0                 1          4  Life Sciences              77   \n",
       "1                 1          4  Life Sciences            1245   \n",
       "2                 7          3  Life Sciences             147   \n",
       "3                 1          1  Life Sciences            1026   \n",
       "4                 1          3        Medical            1111   \n",
       "\n",
       "   EnvironmentSatisfaction  Gender  ...  RelationshipSatisfaction  \\\n",
       "0                        1    Male  ...                         3   \n",
       "1                        4  Female  ...                         1   \n",
       "2                        1    Male  ...                         4   \n",
       "3                        4  Female  ...                         3   \n",
       "4                        1    Male  ...                         1   \n",
       "\n",
       "   StandardHours StockOptionLevel  TotalWorkingYears TrainingTimesLastYear  \\\n",
       "0             80                1                  7                     2   \n",
       "1             80                1                 33                     2   \n",
       "2             80                0                  9                     3   \n",
       "3             80                1                 21                     3   \n",
       "4             80                2                  1                     2   \n",
       "\n",
       "   WorkLifeBalance  YearsAtCompany YearsInCurrentRole YearsSinceLastPromotion  \\\n",
       "0                4               7                  5                       0   \n",
       "1                1               5                  4                       1   \n",
       "2                3               9                  7                       0   \n",
       "3                3              21                  6                      11   \n",
       "4                3               1                  0                       0   \n",
       "\n",
       "   YearsWithCurrManager  \n",
       "0                     7  \n",
       "1                     4  \n",
       "2                     6  \n",
       "3                     8  \n",
       "4                     0  \n",
       "\n",
       "[5 rows x 31 columns]"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Attrition</th>\n",
       "      <th>Age</th>\n",
       "      <th>BusinessTravel</th>\n",
       "      <th>Department</th>\n",
       "      <th>DistanceFromHome</th>\n",
       "      <th>Education</th>\n",
       "      <th>EducationField</th>\n",
       "      <th>EmployeeNumber</th>\n",
       "      <th>EnvironmentSatisfaction</th>\n",
       "      <th>Gender</th>\n",
       "      <th>...</th>\n",
       "      <th>RelationshipSatisfaction</th>\n",
       "      <th>StandardHours</th>\n",
       "      <th>StockOptionLevel</th>\n",
       "      <th>TotalWorkingYears</th>\n",
       "      <th>TrainingTimesLastYear</th>\n",
       "      <th>WorkLifeBalance</th>\n",
       "      <th>YearsAtCompany</th>\n",
       "      <th>YearsInCurrentRole</th>\n",
       "      <th>YearsSinceLastPromotion</th>\n",
       "      <th>YearsWithCurrManager</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>Travel_Rarely</td>\n",
       "      <td>Research &amp; Development</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Life Sciences</td>\n",
       "      <td>77</td>\n",
       "      <td>1</td>\n",
       "      <td>Male</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>54</td>\n",
       "      <td>Travel_Frequently</td>\n",
       "      <td>Research &amp; Development</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>Life Sciences</td>\n",
       "      <td>1245</td>\n",
       "      <td>4</td>\n",
       "      <td>Female</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>33</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>34</td>\n",
       "      <td>Travel_Frequently</td>\n",
       "      <td>Research &amp; Development</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>Life Sciences</td>\n",
       "      <td>147</td>\n",
       "      <td>1</td>\n",
       "      <td>Male</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>9</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>39</td>\n",
       "      <td>Travel_Rarely</td>\n",
       "      <td>Research &amp; Development</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Life Sciences</td>\n",
       "      <td>1026</td>\n",
       "      <td>4</td>\n",
       "      <td>Female</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>21</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>28</td>\n",
       "      <td>Travel_Frequently</td>\n",
       "      <td>Research &amp; Development</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>Medical</td>\n",
       "      <td>1111</td>\n",
       "      <td>1</td>\n",
       "      <td>Male</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 31 columns</p>\n",
       "</div>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-10T05:55:32.807817Z",
     "start_time": "2025-08-10T05:55:32.799815Z"
    }
   },
   "cell_type": "code",
   "source": "data.info()",
   "id": "8789f803213c990c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1100 entries, 0 to 1099\n",
      "Data columns (total 31 columns):\n",
      " #   Column                    Non-Null Count  Dtype \n",
      "---  ------                    --------------  ----- \n",
      " 0   Attrition                 1100 non-null   int64 \n",
      " 1   Age                       1100 non-null   int64 \n",
      " 2   BusinessTravel            1100 non-null   object\n",
      " 3   Department                1100 non-null   object\n",
      " 4   DistanceFromHome          1100 non-null   int64 \n",
      " 5   Education                 1100 non-null   int64 \n",
      " 6   EducationField            1100 non-null   object\n",
      " 7   EmployeeNumber            1100 non-null   int64 \n",
      " 8   EnvironmentSatisfaction   1100 non-null   int64 \n",
      " 9   Gender                    1100 non-null   object\n",
      " 10  JobInvolvement            1100 non-null   int64 \n",
      " 11  JobLevel                  1100 non-null   int64 \n",
      " 12  JobRole                   1100 non-null   object\n",
      " 13  JobSatisfaction           1100 non-null   int64 \n",
      " 14  MaritalStatus             1100 non-null   object\n",
      " 15  MonthlyIncome             1100 non-null   int64 \n",
      " 16  NumCompaniesWorked        1100 non-null   int64 \n",
      " 17  Over18                    1100 non-null   object\n",
      " 18  OverTime                  1100 non-null   object\n",
      " 19  PercentSalaryHike         1100 non-null   int64 \n",
      " 20  PerformanceRating         1100 non-null   int64 \n",
      " 21  RelationshipSatisfaction  1100 non-null   int64 \n",
      " 22  StandardHours             1100 non-null   int64 \n",
      " 23  StockOptionLevel          1100 non-null   int64 \n",
      " 24  TotalWorkingYears         1100 non-null   int64 \n",
      " 25  TrainingTimesLastYear     1100 non-null   int64 \n",
      " 26  WorkLifeBalance           1100 non-null   int64 \n",
      " 27  YearsAtCompany            1100 non-null   int64 \n",
      " 28  YearsInCurrentRole        1100 non-null   int64 \n",
      " 29  YearsSinceLastPromotion   1100 non-null   int64 \n",
      " 30  YearsWithCurrManager      1100 non-null   int64 \n",
      "dtypes: int64(23), object(8)\n",
      "memory usage: 266.5+ KB\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-10T05:55:32.927549Z",
     "start_time": "2025-08-10T05:55:32.898380Z"
    }
   },
   "cell_type": "code",
   "source": "data.describe()",
   "id": "ba821cdb2662eb76",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "         Attrition          Age  DistanceFromHome    Education  \\\n",
       "count  1100.000000  1100.000000       1100.000000  1100.000000   \n",
       "mean      0.161818    36.999091          9.427273     2.922727   \n",
       "std       0.368451     9.037230          8.196694     1.022242   \n",
       "min       0.000000    18.000000          1.000000     1.000000   \n",
       "25%       0.000000    30.000000          2.000000     2.000000   \n",
       "50%       0.000000    36.000000          7.000000     3.000000   \n",
       "75%       0.000000    43.000000         15.000000     4.000000   \n",
       "max       1.000000    60.000000         29.000000     5.000000   \n",
       "\n",
       "       EmployeeNumber  EnvironmentSatisfaction  JobInvolvement     JobLevel  \\\n",
       "count     1100.000000              1100.000000     1100.000000  1100.000000   \n",
       "mean      1028.157273                 2.725455        2.730909     2.054545   \n",
       "std        598.915204                 1.098053        0.706366     1.107805   \n",
       "min          1.000000                 1.000000        1.000000     1.000000   \n",
       "25%        504.250000                 2.000000        2.000000     1.000000   \n",
       "50%       1026.500000                 3.000000        3.000000     2.000000   \n",
       "75%       1556.500000                 4.000000        3.000000     3.000000   \n",
       "max       2065.000000                 4.000000        4.000000     5.000000   \n",
       "\n",
       "       JobSatisfaction  MonthlyIncome  ...  RelationshipSatisfaction  \\\n",
       "count      1100.000000    1100.000000  ...               1100.000000   \n",
       "mean          2.732727    6483.620909  ...                  2.696364   \n",
       "std           1.109731    4715.293419  ...                  1.095356   \n",
       "min           1.000000    1009.000000  ...                  1.000000   \n",
       "25%           2.000000    2924.500000  ...                  2.000000   \n",
       "50%           3.000000    4857.000000  ...                  3.000000   \n",
       "75%           4.000000    8354.500000  ...                  4.000000   \n",
       "max           4.000000   19999.000000  ...                  4.000000   \n",
       "\n",
       "       StandardHours  StockOptionLevel  TotalWorkingYears  \\\n",
       "count         1100.0       1100.000000        1100.000000   \n",
       "mean            80.0          0.788182          11.221818   \n",
       "std              0.0          0.843347           7.825548   \n",
       "min             80.0          0.000000           0.000000   \n",
       "25%             80.0          0.000000           6.000000   \n",
       "50%             80.0          1.000000          10.000000   \n",
       "75%             80.0          1.000000          15.000000   \n",
       "max             80.0          3.000000          40.000000   \n",
       "\n",
       "       TrainingTimesLastYear  WorkLifeBalance  YearsAtCompany  \\\n",
       "count            1100.000000      1100.000000     1100.000000   \n",
       "mean                2.807273         2.746364        7.011818   \n",
       "std                 1.291514         0.701121        6.223093   \n",
       "min                 0.000000         1.000000        0.000000   \n",
       "25%                 2.000000         2.000000        3.000000   \n",
       "50%                 3.000000         3.000000        5.000000   \n",
       "75%                 3.000000         3.000000        9.000000   \n",
       "max                 6.000000         4.000000       37.000000   \n",
       "\n",
       "       YearsInCurrentRole  YearsSinceLastPromotion  YearsWithCurrManager  \n",
       "count         1100.000000              1100.000000           1100.000000  \n",
       "mean             4.207273                 2.226364              4.123636  \n",
       "std              3.618115                 3.313830              3.597996  \n",
       "min              0.000000                 0.000000              0.000000  \n",
       "25%              2.000000                 0.000000              2.000000  \n",
       "50%              3.000000                 1.000000              3.000000  \n",
       "75%              7.000000                 3.000000              7.000000  \n",
       "max             18.000000                15.000000             17.000000  \n",
       "\n",
       "[8 rows x 23 columns]"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Attrition</th>\n",
       "      <th>Age</th>\n",
       "      <th>DistanceFromHome</th>\n",
       "      <th>Education</th>\n",
       "      <th>EmployeeNumber</th>\n",
       "      <th>EnvironmentSatisfaction</th>\n",
       "      <th>JobInvolvement</th>\n",
       "      <th>JobLevel</th>\n",
       "      <th>JobSatisfaction</th>\n",
       "      <th>MonthlyIncome</th>\n",
       "      <th>...</th>\n",
       "      <th>RelationshipSatisfaction</th>\n",
       "      <th>StandardHours</th>\n",
       "      <th>StockOptionLevel</th>\n",
       "      <th>TotalWorkingYears</th>\n",
       "      <th>TrainingTimesLastYear</th>\n",
       "      <th>WorkLifeBalance</th>\n",
       "      <th>YearsAtCompany</th>\n",
       "      <th>YearsInCurrentRole</th>\n",
       "      <th>YearsSinceLastPromotion</th>\n",
       "      <th>YearsWithCurrManager</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.0</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "      <td>1100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.161818</td>\n",
       "      <td>36.999091</td>\n",
       "      <td>9.427273</td>\n",
       "      <td>2.922727</td>\n",
       "      <td>1028.157273</td>\n",
       "      <td>2.725455</td>\n",
       "      <td>2.730909</td>\n",
       "      <td>2.054545</td>\n",
       "      <td>2.732727</td>\n",
       "      <td>6483.620909</td>\n",
       "      <td>...</td>\n",
       "      <td>2.696364</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.788182</td>\n",
       "      <td>11.221818</td>\n",
       "      <td>2.807273</td>\n",
       "      <td>2.746364</td>\n",
       "      <td>7.011818</td>\n",
       "      <td>4.207273</td>\n",
       "      <td>2.226364</td>\n",
       "      <td>4.123636</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.368451</td>\n",
       "      <td>9.037230</td>\n",
       "      <td>8.196694</td>\n",
       "      <td>1.022242</td>\n",
       "      <td>598.915204</td>\n",
       "      <td>1.098053</td>\n",
       "      <td>0.706366</td>\n",
       "      <td>1.107805</td>\n",
       "      <td>1.109731</td>\n",
       "      <td>4715.293419</td>\n",
       "      <td>...</td>\n",
       "      <td>1.095356</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.843347</td>\n",
       "      <td>7.825548</td>\n",
       "      <td>1.291514</td>\n",
       "      <td>0.701121</td>\n",
       "      <td>6.223093</td>\n",
       "      <td>3.618115</td>\n",
       "      <td>3.313830</td>\n",
       "      <td>3.597996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1009.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>504.250000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2924.500000</td>\n",
       "      <td>...</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>36.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1026.500000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4857.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>43.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>1556.500000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>8354.500000</td>\n",
       "      <td>...</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>7.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>60.000000</td>\n",
       "      <td>29.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>2065.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>19999.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>80.0</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>40.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>37.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>17.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 23 columns</p>\n",
       "</div>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-10T05:55:33.112816Z",
     "start_time": "2025-08-10T05:55:33.106423Z"
    }
   },
   "cell_type": "code",
   "source": "data[['EmployeeNumber', 'StandardHours', 'Over18']]",
   "id": "a033269b98c3570c",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      EmployeeNumber  StandardHours Over18\n",
       "0                 77             80      Y\n",
       "1               1245             80      Y\n",
       "2                147             80      Y\n",
       "3               1026             80      Y\n",
       "4               1111             80      Y\n",
       "...              ...            ...    ...\n",
       "1095              75             80      Y\n",
       "1096            1835             80      Y\n",
       "1097             868             80      Y\n",
       "1098            1878             80      Y\n",
       "1099            1053             80      Y\n",
       "\n",
       "[1100 rows x 3 columns]"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>EmployeeNumber</th>\n",
       "      <th>StandardHours</th>\n",
       "      <th>Over18</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>77</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1245</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>147</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1026</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1111</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1095</th>\n",
       "      <td>75</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1096</th>\n",
       "      <td>1835</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1097</th>\n",
       "      <td>868</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1098</th>\n",
       "      <td>1878</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1099</th>\n",
       "      <td>1053</td>\n",
       "      <td>80</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1100 rows × 3 columns</p>\n",
       "</div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-08-10T05:56:29.570050Z",
     "start_time": "2025-08-10T05:56:29.562488Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 类别列one-hot编码\n",
    "categorical_cols = data.select_dtypes(include=['object']).columns.tolist()\n",
    "# print(categorical_cols)\n",
    "data = pd.get_dummies(data, columns=categorical_cols, drop_first=True)\n",
    "print(data.info())"
   ],
   "id": "82f90c50942ff830",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1100 entries, 0 to 1099\n",
      "Data columns (total 42 columns):\n",
      " #   Column                             Non-Null Count  Dtype\n",
      "---  ------                             --------------  -----\n",
      " 0   Attrition                          1100 non-null   int64\n",
      " 1   Age                                1100 non-null   int64\n",
      " 2   DistanceFromHome                   1100 non-null   int64\n",
      " 3   Education                          1100 non-null   int64\n",
      " 4   EnvironmentSatisfaction            1100 non-null   int64\n",
      " 5   JobInvolvement                     1100 non-null   int64\n",
      " 6   JobLevel                           1100 non-null   int64\n",
      " 7   JobSatisfaction                    1100 non-null   int64\n",
      " 8   MonthlyIncome                      1100 non-null   int64\n",
      " 9   NumCompaniesWorked                 1100 non-null   int64\n",
      " 10  PercentSalaryHike                  1100 non-null   int64\n",
      " 11  PerformanceRating                  1100 non-null   int64\n",
      " 12  RelationshipSatisfaction           1100 non-null   int64\n",
      " 13  StockOptionLevel                   1100 non-null   int64\n",
      " 14  TotalWorkingYears                  1100 non-null   int64\n",
      " 15  TrainingTimesLastYear              1100 non-null   int64\n",
      " 16  WorkLifeBalance                    1100 non-null   int64\n",
      " 17  YearsAtCompany                     1100 non-null   int64\n",
      " 18  YearsInCurrentRole                 1100 non-null   int64\n",
      " 19  YearsSinceLastPromotion            1100 non-null   int64\n",
      " 20  YearsWithCurrManager               1100 non-null   int64\n",
      " 21  BusinessTravel_Travel_Frequently   1100 non-null   bool \n",
      " 22  BusinessTravel_Travel_Rarely       1100 non-null   bool \n",
      " 23  Department_Research & Development  1100 non-null   bool \n",
      " 24  Department_Sales                   1100 non-null   bool \n",
      " 25  EducationField_Life Sciences       1100 non-null   bool \n",
      " 26  EducationField_Marketing           1100 non-null   bool \n",
      " 27  EducationField_Medical             1100 non-null   bool \n",
      " 28  EducationField_Other               1100 non-null   bool \n",
      " 29  EducationField_Technical Degree    1100 non-null   bool \n",
      " 30  Gender_Male                        1100 non-null   bool \n",
      " 31  JobRole_Human Resources            1100 non-null   bool \n",
      " 32  JobRole_Laboratory Technician      1100 non-null   bool \n",
      " 33  JobRole_Manager                    1100 non-null   bool \n",
      " 34  JobRole_Manufacturing Director     1100 non-null   bool \n",
      " 35  JobRole_Research Director          1100 non-null   bool \n",
      " 36  JobRole_Research Scientist         1100 non-null   bool \n",
      " 37  JobRole_Sales Executive            1100 non-null   bool \n",
      " 38  JobRole_Sales Representative       1100 non-null   bool \n",
      " 39  MaritalStatus_Married              1100 non-null   bool \n",
      " 40  MaritalStatus_Single               1100 non-null   bool \n",
      " 41  OverTime_Yes                       1100 non-null   bool \n",
      "dtypes: bool(21), int64(21)\n",
      "memory usage: 203.2 KB\n",
      "None\n"
     ]
    }
   ],
   "execution_count": 12
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
